package com.hngtrust.iir.base.controller;
/*******************************************************************************
 * Package: com.hngtrust.bazhe.controller
 * Type:    BazheController
 * Date:    2022/1/6 16:46
 *
 * Copyright (c) 2022 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/

import com.hngtrust.iir.base.entity.Shop;
import com.hngtrust.iir.base.service.BazheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * TODO your comment
 *
 * @author Wangheng
 * @date 2022/1/6 16:46
 */

@Controller
@RequestMapping("/bazhe2")
public class Bazhe2Controller {
    @Autowired
    private BazheService bazheService;
    
    
    @PostMapping("/queryById/{id}")
    public String queryById(@PathVariable("id") Integer id, ModelMap modelMap){
        Shop shop = bazheService.queryById(id);
        modelMap.put("query2",shop);
    return "bazhe";
    }
   
    @PostMapping("/queryList")
    @ResponseBody
    public List<Shop> queryList(@RequestBody Shop shop){
        return bazheService.queryList(shop);
    }
    @PostMapping("/add")
    @ResponseBody
    public void add(@RequestBody Shop shop){
         bazheService.add(shop);
    }
    
    
    @PostMapping("/modifyById")
    @ResponseBody
    public void modifyById(@RequestBody Shop shop){
        bazheService.modifyById(shop);
    }
    
    
    @PostMapping("/deleteById/{id}")
    @ResponseBody
    public void deleteById(@PathVariable("id") Integer id){
        bazheService.deleteById(id);
    }
    
    
    @PostMapping("/queryShop")
    @ResponseBody
    public List<Shop> queryShop(@RequestBody Shop shop){
       return bazheService.queryShop(shop);
    }
    
    
    @PostMapping("/queryByIds/{ids}")
    @ResponseBody
    public List<Shop>  queryShop(@PathVariable("ids") List<Integer> ids) {
       return bazheService.queryByIds(ids);
    }
}
